###############################################################################
# SuperLinks                                                                  #
# Copyright (c) 2000-2007 Greg Nolle (http://greg.nolle.co.uk)                #
###############################################################################
# This program is free software; you can redistribute it and/or modify it     #
# under the terms of the GNU General Public License as published by the Free  #
# Software Foundation; either version 2 of the License, or (at your option)   #
# any later version.                                                          #
#                                                                             #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   #
# more details.                                                               ##                                                                             #
# You should have received a copy of the GNU General Public License along     #
# with this program; if not, write to the Free Software Foundation, Inc.,     #
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                 #
###############################################################################
# Output/Index.pm.pl -> Index module                                          #
###############################################################################
# DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!                         #
###############################################################################
package Skin::Index;

BEGIN { require "System.pm.pl"; import System qw($SYSTEM); }
BEGIN { require "General.pm.pl"; import General qw($GENERAL); }
require "Standard.pm.pl";

use strict;

sub new {
  my ($class) = @_;
  my $self    = {};
  return bless ($self, $class);
}

sub DESTROY { }

###############################################################################
# show subroutine
sub show {
  my $self = shift;
  my %in = ("input" => undef, "static" => 0, @_);

  #----------------------------------------------------------------------#
  # Preparing data...                                                    #

  if ($in{'input'}->{'FEATURED'}) {
    $in{'input'}->{'FEATURED'}->{'NEW1'}    = (($in{'input'}->{'FEATURED'}->{'CREATE_SECOND'} >= (time - $GENERAL->{'NEW1_CUTOFF'} * 24 * 60 * 60) && $in{'input'}->{'FEATURED'}->{'CREATE_SECOND'} < (time - $GENERAL->{'NEW2_CUTOFF'} * 24 * 60 * 60)) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'NEW2'}    = (($in{'input'}->{'FEATURED'}->{'CREATE_SECOND'} >= (time - $GENERAL->{'NEW2_CUTOFF'} * 24 * 60 * 60) && $in{'input'}->{'FEATURED'}->{'CREATE_SECOND'} < (time - $GENERAL->{'NEW3_CUTOFF'} * 24 * 60 * 60)) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'NEW3'}    = (($in{'input'}->{'FEATURED'}->{'CREATE_SECOND'} >= (time - $GENERAL->{'NEW3_CUTOFF'} * 24 * 60 * 60)) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'HOT1'}    = (($in{'input'}->{'FEATURED'}->{'HITS'} >= $GENERAL->{'HOT1_CUTOFF'} && $in{'input'}->{'FEATURED'}->{'HITS'} < $GENERAL->{'HOT2_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'HOT2'}    = (($in{'input'}->{'FEATURED'}->{'HITS'} >= $GENERAL->{'HOT2_CUTOFF'} && $in{'input'}->{'FEATURED'}->{'HITS'} < $GENERAL->{'HOT3_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'HOT3'}    = (($in{'input'}->{'FEATURED'}->{'HITS'} >= $GENERAL->{'HOT3_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'COOL1'}   = (($in{'input'}->{'FEATURED'}->{'RATING'} >= $GENERAL->{'COOL1_CUTOFF'} && $in{'input'}->{'FEATURED'}->{'RATING'} < $GENERAL->{'COOL2_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'COOL2'}   = (($in{'input'}->{'FEATURED'}->{'RATING'} >= $GENERAL->{'COOL2_CUTOFF'} && $in{'input'}->{'FEATURED'}->{'RATING'} < $GENERAL->{'COOL3_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'COOL3'}   = (($in{'input'}->{'FEATURED'}->{'RATING'} >= $GENERAL->{'COOL3_CUTOFF'}) ? 1 : 0);
    $in{'input'}->{'FEATURED'}->{'UPDATED'} = (($in{'input'}->{'FEATURED'}->{'UPDATE_SECOND'} > $in{'input'}->{'FEATURED'}->{'CREATE_SECOND'}) ? 1 : 0);
  
    $in{'input'}->{'FEATURED'}->{'flags'}   = &Standard::ArrayToHash([ split(/,/, $in{'input'}->{'FEATURED'}->{'FLAGS'}) ]);
    $in{'input'}->{'FEATURED'}->{'extra'}   = eval($in{'input'}->{'FEATURED'}->{'EXTRA'});
  }

  my %FIELDS;

  $FIELDS{'featured'}   = $in{'input'}->{'FEATURED'};
  $FIELDS{'categories'} = $in{'input'}->{'CATEGORIES'};
  $FIELDS{'totals'}     = {
    RESOURCES => $in{'input'}->{'TOTAL_RESOURCES'}
  };

  foreach my $category (@{ $in{'input'}->{'CATEGORIES'} }) {
    $category->{'extra'} = eval($category->{'EXTRA'});
  }

  #----------------------------------------------------------------------#
  # Printing page...                                                     #

  return &Standard::Substitute(
    INPUT     => ($in{'static'} ? "Static/Index.htm" : "Index.htm"),
    STANDARD  => 1,
    FIELDS    => \%FIELDS
  );
}

1;